package com.atguigu.dga.governance.scheduler;


import com.atguigu.dga.governance.service.impl.GovernanceAssessDetailServiceImpl;
import com.atguigu.dga.governance.service.impl.GovernanceAssessGlobalServiceImpl;
import com.atguigu.dga.governance.service.impl.GovernanceAssessTableServiceImpl;
import com.atguigu.dga.governance.service.impl.GovernanceAssessTecOwnerServiceImpl;
import com.atguigu.dga.meta.service.impl.TableMetaInfoServiceImpl;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.thrift.TException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Date;

@Component
public class AssessScheduler {

    @Autowired
    TableMetaInfoServiceImpl tableMetaInfoService;


    @Autowired
    GovernanceAssessDetailServiceImpl governanceAssessDetailService;

    @Autowired
    GovernanceAssessTableServiceImpl governanceAssessTableService;

    @Autowired
    GovernanceAssessTecOwnerServiceImpl governanceAssessTecOwnerService;
    @Autowired
    GovernanceAssessGlobalServiceImpl governanceAssessGlobalService;


    @Scheduled(cron = "0/5 * * * * *")
    public void testScheduler() throws Exception {
        System.out.println(System.currentTimeMillis());
    }


    @Scheduled(cron = "0 30 2 * * *")  //夜里两点半
    public  void  mainAssess() throws  Exception {
        String assessDate = DateFormatUtils.format(new Date(), "yyyy-MM-dd");

        assessDate="2023-05-02";
        tableMetaInfoService.initTableMetaInfo(assessDate);
        governanceAssessDetailService.governanceAssess(assessDate);
        governanceAssessTableService.generateAssessTable(assessDate);
        governanceAssessTecOwnerService.generateAssessTecOwner(assessDate);
        governanceAssessGlobalService.generateAssess(assessDate);
    }




}
